package pers.sports.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pers.sports.dao.NoticeDao;
import pers.sports.entity.Notice;
import pers.sports.service.NoticeService;
import pers.sports.vo.NoticeInfo;

import java.util.List;

/**
 * 公告服务
 *
 * @datetime 2021/3/30 14:44
 */
@Service
public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeDao noticeDao;

    @Override
    @Transactional(readOnly = true)
    public List<NoticeInfo> findAllNoticeInfo(Integer page, Integer limit) {
        Integer b = (page-1)+((page-1)*limit);
        List<NoticeInfo> list = noticeDao.findAllNoticeInfo(b,limit);
        return list;
    }

    @Override
    public Notice findNoticeById(String noticeId) {
        Notice notice = noticeDao.findNoticeById(noticeId);
        return notice;
    }

    @Override
    public Boolean insertNotice(Notice notice) {
        return noticeDao.insertNotice(notice) != 0 ? true : false;
    }

    @Override
    public Integer countNumber() {
        return noticeDao.countNumber();
    }

    @Override
    public void deleteNoticeById(String s) {
        noticeDao.deleteNoticeById(s);
    }
}
